﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Caching;

namespace Aandelendelen.News
{
	public class NewsCache
	{
		internal static NewsItemCollection GetNews()
		{
			string cacheName = "news";

			NewsItemCollection news = NewsCache.Cache[cacheName] as NewsItemCollection;

			if (news == null)
			{
				news = new NewsItemCollection();

				CacheDependency dependency = new CacheDependency(HttpContext.Current.Server.MapPath("/App_Data/News.xml"));

				NewsCache.Cache.Insert(cacheName, news, dependency);
			}

			return news;
		}

		private static Cache Cache
		{
			get { return HttpContext.Current.Cache; }
		}

	}
}